-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BYOM] Move from "OAI" naming convention to "BYOM" #27043
Conversation
b489da7
to
a9d696c
Compare
With the growth of the BYOM model, Brave aims to support popular service endpoints. Originally, the OpenAI model was supported, which was reflected in relevant files and code. With the growing adoption of alternatives (e.g., Ollama locally, Anthropic, Perplexity, Azure hosted models, etc.), it is important to avoid confusion throughout the codebase. This change therefore partially renames files to reflect the move from "oai" to "byom", as well as updates classes, header files, and more. This migration lays the groundwork for a clearer, more maintainable path towards supporting even more endpoints and API patterns. Also, this change addresses the presubmit warnings associated with associated unit tests (specifically, a couple lines of JSON within).
d4d868a
to
439cff3
Compare
I'm not sure what we gain by renaming these files. If we offered the user the option to switch between OAI and Anthropic API then we'd use an Anthropic API client and not the OpenAI API client right? Similarly if we expose an OpenAI endpoint for some Leo functions then we'd most likely use the existing client. |
The OAI files are currently serving OpenAI, Ollama, Azure endpoints and more (each of which partially implement the OpenAI API spec, but with subtle differences). Rather than potentially making ongoing changes within the "OpenAI" files, I'm proposing we rename the existing files to something more generic (i.e., "BYOM" files), and then (as needed) create service-specific files for particular providers. As you suggest, this would mean the introduction of files for Anthropic, Perplexity, and more (which is what I had planned as a follow-up on this PR). The reason I went this route (as opposed to simply creating an entirely new anthropic_api_client.cc) was to maintain a common API client with distinct methods for handling headers and responses. Rather than creating largely redundant code, I thought it would be better to instead enable us to provide provider-specific methods for constructing headers for requests, as well as handling responses. That said, I'm more than happy to take an approach that is more consistent with our current solution, and keep that logic encapsulated at the provider class level, creating distinct *_api_client.cc files, etc. Your call :) |
We have an established pattern of providing distinct API Client classes for different endpoints. While it is presently the case that our OpenAI Client handles OpenAI, Ollama, and more, it is still quite basic and straight-forward. The goal of this PR was to introduce alternative branches of logic (specific to particular providers) for constructing requests, and handling responses. It is probably wise not to deviate from the current path of keeping platform-specific logic confined to API Client classes, rather than introducing smaller platform-specific classes aimed at handling requests-construction and response-parsing alone. As such, I'm going to close this issue and focus instead on introducing additional API Clients for presently-unsupported providers. |
With the growth of the BYOM model, Brave aims to support popular service endpoints. Originally, the OpenAI model was supported, which was reflected in relevant files and code. With the growing adoption of alternatives (e.g., Ollama locally, Anthropic, Perplexity, Azure hosted models, etc.), it is important to avoid confusion throughout the codebase. This change therefore partially renames files to reflect the move from "oai" to "byom", as well as updates classes, header files, and more. This migration lays the groundwork for a clearer, more maintainable path towards supporting even more endpoints and API patterns.
Resolves brave/brave-browser#42936
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: